<?
require_once(dirname(dirname(dirname(__FILE__))) . "/_includes/config.php");
require_once(dirname(dirname(dirname(__FILE__))) . "/_includes/classes/paginacao.class.php");

if ($_REQUEST['form_enviado'] == 1){ 
	$nu_cep = $_REQUEST['nu_cep'];
}
?>

<h2>1 | Selecione o CEP</h2>
<form name="form1" method="post" action="">
  <div class="formArea">
    
<table border="0" cellpadding="0" cellspacing="0" class="formCampos">
  <tr> 
    <td class="formLabel">CEP:</td>
    <td> 
		<input name="nu_cep" type="text" class="formInput formGrande" value="<?=$nu_cep?>">
  	</td>
  </tr>
  <tr>
    <td class="formLabel">&nbsp;</td>
    <td>
		<input name="formButtonOk" type="submit" class="formButton" id="formButtonOk" value="OK"> 
		<input name="form_enviado" type="hidden" id="form_enviado" value="1">
	</td>
  </tr>
</table>
</form>
<?
$sql = "SELECT nu_cep, dc_municipio FROM cep a Inner Join municipio b On a.cd_municipio = b.cd_municipio WHERE nu_cep = '$nu_cep'";
$pg = new paginacao($sql);
$pg->consulta;

$pg->cabecalho = '
  <tr class="linhaHeader">
    <td>Munic&iacute;pio</td>
    <td width="80%">CEP</td>
  </tr>
  ';

$pg->linha = '
  <tr class="linha<?=$c&1?>" onMouseOver="this.className=\'linhaOver\'; this.style.cursor=\'pointer\'" onMouseOut="this.className=\'linha<?=$c++&1?>\'" onClick="window.location.href=\'?nu_cep=<?=$lst[\'nu_cep\']. "&" . $_SERVER[\'QUERY_STRING\']?>\'">
    <td><?=$lst[\'dc_municipio\']?></td>
	<td><?=$lst[\'nu_cep\']?></td>
  </tr>
  ';

$pg->resultado(); 
	
?>